//
//  TopicTableViewCell.m
//  news
//
//  Created by Qiaobuyong on 16/3/11.
//  Copyright © 2016年 imacbookair. All rights reserved.
//

#import "TopicTableViewCell.h"
#define KWITH [UIScreen mainScreen].bounds.size.width /375
#define KHIGHT [UIScreen mainScreen].bounds.size.height /667
@implementation TopicTableViewCell
#pragma mark -  初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 背景图片
        self.background = [[UIImageView alloc] init];
        //        _beijing.backgroundColor = [UIColor redColor];
        _background.image = [UIImage imageNamed:@"bg"];
        [self.contentView addSubview:_background];

        
        // 大图
        self.image = [[UIImageView alloc] init];
        //        _tu.backgroundColor = [UIColor yellowColor];
        [self.background addSubview:_image];

        
        // 头像
        self.headImage = [[UIImageView alloc] init];
        //        _touxiang.backgroundColor = [UIColor cyanColor];
        [self.image addSubview:_headImage];

        
        // name
        self.name = [[UILabel alloc] init];
        _name.textColor = [UIColor whiteColor];
        //        _name.backgroundColor = [UIColor cyanColor];
        [self.image addSubview:_name];

        
        // title
        self.title = [[UILabel alloc] init];
        _title.numberOfLines = 2;
        //        _title.backgroundColor = [UIColor magentaColor];
        [self.background addSubview:_title];

        
        // 关注
        self.comment = [[UILabel alloc] init];
        _comment.font = [UIFont systemFontOfSize:12];
        _comment.textAlignment = NSTextAlignmentRight;
        //        _guanzhu.backgroundColor = [UIColor purpleColor];
        [self.background addSubview:_comment];

        
        // 类型
        self.kind = [[UILabel alloc] init];
        _kind.font = [UIFont systemFontOfSize:12];
        _kind.textAlignment = NSTextAlignmentCenter;
        _kind.textColor = [UIColor blueColor];
        //        _lei.backgroundColor = [UIColor cyanColor];
        [self.background addSubview:_kind];

        
        // 状态
        self.state = [[UILabel alloc] init];
        _state.font = [UIFont systemFontOfSize:12];
        _state.textAlignment = NSTextAlignmentLeft;
        //        _zhuangtai.backgroundColor = [UIColor blueColor];
        [self.background addSubview:_state];

        
        // button
        self.commentButton = [UIButton buttonWithType:UIButtonTypeSystem];
        //        _guan.backgroundColor = [UIColor blackColor];
        [_commentButton setTitle:@"+ 关注" forState:UIControlStateNormal];
        [_commentButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        _commentButton.layer.borderWidth = 0.2;
        _commentButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
        [self.background addSubview:_commentButton];
        
    }
    return self;
}

#pragma mark - 布局
- (void)layoutSubviews
{
    [super layoutSubviews];
    _background.frame               = CGRectMake(10 * KWITH, 5 * KHIGHT, self.contentView.frame.size.width - 20, 280 * KHIGHT);
    _image.frame                    = CGRectMake(0, 0, self.contentView.frame.size.width - 20, 180 * KHIGHT);
    _headImage.frame              = CGRectMake(10 * KWITH, 120 * KHIGHT, 40 * KWITH, 40 * KHIGHT);
    _headImage.layer.cornerRadius = 40 * KWITH / 2;
    _name.frame                  = CGRectMake(60 * KWITH, 130 * KHIGHT, 70 * KWITH, 20 * KHIGHT);
    _title.frame                 = CGRectMake(5 * KWITH, 180 * KHIGHT, self.contentView.frame.size.width - 30, 50 * KHIGHT);
    _comment.frame               = CGRectMake(5 * KWITH, 240 * KHIGHT, 80 * KWITH, 20 * KHIGHT);
    _kind.frame                   = CGRectMake(85 * KWITH, 240 * KHIGHT, 30 * KWITH, 20 * KHIGHT);
    _state.frame             = CGRectMake(115 * KWITH, 240 * KHIGHT, 50 * KWITH, 20 * KHIGHT);
    _commentButton.frame                  = CGRectMake(280 * KWITH, 235 * KHIGHT, 60 * KWITH, 30 * KHIGHT);
    _commentButton.layer.cornerRadius     = 15 * KWITH;

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
